package com.patternsbox.behavioral.iterator;

import com.patternsbox.ActionTemplate;

public class IteratorAction extends ActionTemplate {

	public void doAction() {
        Aggregate a = new ConcreteAggregate();
        a.add("Item A");
        a.add("Item B");
        a.add("Item C");
        a.add("Item D");
        
        // Create Iterator and provide aggregate
        Iterator iterator = a.createIterator();
        System.out.println("Iterating over collection:");

        Object item = iterator.first();

        while (!iterator.isDone())
        {
        	System.out.println(item);
            item = iterator.next();
        }
	}
}
